package com.fau.hm.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.hibernate.annotations.GenericGenerator;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc 登录日志表
 * @author liy
 * @datetime 2014年10月16日,下午12:07:03
 */
@Entity
@Table(name = "medical_log")
public class MedicalLog implements Serializable, JSONAware {

	private static final long serialVersionUID = 6377252680303489230L;

	private String id;
	private String userName;			// 用户名
	private String content;				// 日志内容
	private String ip;					// 登录ip
	private Date logTime = new Date();	// 登录时间
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "log_time")
	public Date getLogTime() {
		return logTime;
	}

	public void setLogTime(Date logTime) {
		this.logTime = logTime;
	}

	@Column(name = "user_name", length = 10)
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Column(name = "content", length = 100)
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Column(name = "ip", length = 50)
	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		obj.put("userName", userName);
		obj.put("content", content);
		obj.put("ip", ip);
		obj.put("logTime", DateFormatUtils.format(logTime, "yyyy-MM-dd HH:mm:ss"));
		return obj.toString();
	}
	
}
